package com.tecode.config;

import com.tecode.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;

/**
 * 配置类，等价于Spring的配置文件
 *
 * @Configuration  表示当前类 是一个注册类
 * @ComponentScan(value = "com.tecode")  包的扫描
 *              value属性：需扫描包
 *              excludeFilters:不需要扫描的
                                excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})
                                       @ComponentScan.Filter：不扫描的类型    classes 具体的注解类
 *              includeFilters属性：值扫描的
 *                               includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})}
 *              useDefaultFilters = false   设置取消默认的扫描行为
 *
 *              @ComponentScan(value = "com.tecode",excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})},
                    includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})},useDefaultFilters = false)
 */

@Configuration
@ComponentScan(value = "com.tecode",excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})},
        includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})},useDefaultFilters = false)
public class ManConfig {

    /**
     *  @Bean  注解  表示向Spring容器中注册一个bean，类型为返回值类型，id，默认是方法得当名称
     *              也可以使用Bean注解的value属性来指定id的值；
     * @return
     */
    @Bean(value = "person")
    public Person getPerson(){
        return  new Person(1001,"tom");
    }


}
